<?php
	class extendsControl extends commonControl{
		/**
		 * 显示友情链接
		 */
		public function links_show(){
			$links = M('flink');
			$row = $links->order(' sort asc')->all();
			$this->assign('links', $row);
			$this->display();
		}
		/**
		 * 修改排序
		 */
		public function links_sort(){
			$links = M('flink');
			foreach($_POST['sort'] as $k=>$v){
				$data = array('fid'=>$k,'sort'=>$v);
				$links->update($data);
			}
			$this->success('排序修改成功');
		}
		/**
		 * 增加友情链接页面
		 */
		public function links_add_show(){
			$this->display();
		}
		/**
		 * 执行增加友情链接
		 */
		public function links_add_exe(){
// 			$upload = new upload('./upload/links','','',0,1,array(120,70));
// 			$file = $upload->upload();
// 			p($file);
			//P($_FILES);
			//P($_POST);exit;
			$_POST['logo'] = $_POST['logo'][1][1];
			$_POST['logo'] = $_POST['logo']['basename'];
			$links = M('flink');
			$_POST['addtime'] = time();
			if($links->add()){
				$this->success('添加成功');
			}else{
				$this->error('添加失败');
			}
		}
		/**
		 * 友情链接修改
		 */
		public function links_modify(){
			$links = M('flink');
			$row = $links->where(" fid = '".$_GET['fid']."'")->find();
			$this->assign('links', $row);
			$this->display();
		}
		/**
		 * 执行友情链接修改
		 */
		public function links_modify_exe(){
			
			$links = M('flink');
			$_POST['logo'] = pathinfo($_POST['logo'][1][1]);
			$_POST['logo'] = $_POST['logo']['basename'];
			if($links->where(" fid = '".$_POST['fid']."'")->update()){
				$this->success('修改成功');
			}else{
				$this->error('可惜，修改失败了！');
			}
		}
		/**
		 * 执行链接删除
		 */
		public function links_del(){
			P($_GET);
			$links = M('flink');
			if($links->where(" fid = '".$_GET['fid']."'")->del()){
				$this->success('删除成功!');
			}else{
				$this->error('删除失败!');
			}
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
?>